<?php

//directories:
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

defined('WEB_ROOT')
    || define('WEB_ROOT', realpath(APPLICATION_PATH . '/../public'));

defined('VAR_DIR')
    || define('VAR_DIR', realpath(dirname(__FILE__) . '/../var'));

defined('USR_DIR')
    || define('USR_DIR', realpath(dirname(__FILE__) . '/../usr'));

defined('DEFAULT_CONFIG_DIR')
    || define('DEFAULT_CONFIG_DIR', realpath(APPLICATION_PATH . '/configs'));

defined('USR_CONFIG_DIR')
    || define('USR_CONFIG_DIR', realpath(USR_DIR . '/configs'));
    
defined('MODULES_PATH')
    || define('MODULES_PATH', realpath(APPLICATION_PATH . '/modules')); 

//set library path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(dirname(__FILE__) . '/../library'),
    get_include_path(),
)));

//debug
function debug($param) {
    echo '<pre>';
    print_r($param);
    echo '</pre>';
}

//autoload
function __autoload($className) {
    require_once $className = str_replace('_', '/', $className) . '.php';
}

//bootstrap
require_once APPLICATION_PATH . '/Bootstrap.php';
Bootstrap::getInstance()->run();

//dispatch
//Zend_Controller_Front::getInstance()->dispatch();